package com.psa.tool;

import android.content.Context;
import android.telephony.TelephonyManager;
import android.util.Log;
import com.wxw.BaseLibrary.tool.GetAndroidUniqueMark;


/**
 *
 * @author david
 * @date 14-3-20
 */
public class PhoneState {
    public static String NoDeviceId = "No DeviceId";

    public static Object getPhoneState(PHONE_STATE phone_state, Context context){
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        Object o = null;
        try {
            switch (phone_state) {
                case CallState:
                    o = tm.getCallState();//int
                    break;
                case CellLocation:
                    o = tm.getCellLocation();//CellLocation
                    break;
                case DeviceId:
                    o = (tm.getDeviceId() != null ? tm.getDeviceId() : GetAndroidUniqueMark.getUniqueId(context));//String
                    break;
                case DeviceSoftwareVersion:
                    o = tm.getDeviceSoftwareVersion();//String
                    break;
                case Line1Number:
                    o = tm.getLine1Number();//String
                    break;
                case NeighboringCellInfo:
                    o = tm.getNeighboringCellInfo();//List<NeighboringCellInfo>
                    break;
                case NetworkCountryIso:
                    o = tm.getNetworkCountryIso();//String
                    break;
                case NetworkOperator:
                    o = tm.getNetworkOperator();//String
                    break;
                case NetworkOperatorName:
                    o = tm.getNetworkOperatorName();//String
                    break;
                case NetworkType:
                    o = tm.getNetworkType();//int
                    break;
                case PhoneType:
                    o = tm.getPhoneType();//int
                    break;
                case SimCountryIso:
                    o = tm.getSimCountryIso();//String
                    break;
                case SimOperator:
                    o = tm.getSimOperator();//String
                    break;
                case SimOperatorName:
                    o = tm.getSimOperatorName();//String
                    break;
                case SimSerialNumber:
                    o = tm.getSimSerialNumber();//String
                    break;
                case SimState:
                    o = tm.getSimState();//int
                    break;
                case SubscriberId:
                    o = tm.getSubscriberId();//String
                    break;
                case VoiceMailAlphaTag:
                    o = tm.getVoiceMailAlphaTag();//String
                    break;
                case VoiceMailNumber:
                    o = tm.getVoiceMailNumber();//String
                    break;
                case HasIccCard:
                    o = tm.hasIccCard();//boolean
                    break;
                case IsNetworkRoaming:
                    o = tm.isNetworkRoaming();//boolean
                    break;
                default:
                    o = null;
                    break;
            }
            o = o == null? "":o;
        } catch (Exception e) {
            Log.e(SystemStatus.TAG, e.getMessage());
            return "no";
        }
        return o;
    }
}
